<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$plugin_name =$this->pluginname;
if(!$this->plugin_exists('jy_kabao')){
	exi('请先安装【线下卡包系统】插件！','error','/index/');
}
if($_RQ['op']=='get'){
	//显示统计数据
		$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		$mounthtime =  mktime(0,0,0,date('m'),1,date('Y'));
		$access=array();
		$filename=$_SESSION['role_id']==2?'storeid':'workerid';
		$filevalue=$_SESSION['role_id']==2?$this->store_id:$this->worker_id;
		$access['look_day']=pdo_count('jy_kabao_batch_code',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name,'looktime >'=>$daytime));
		$access['code_day']=pdo_count('jy_kabao_batch_code',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name,'createtime >'=>$daytime));
		$access['order_day']=pdo_count('jy_kabao_batch_code',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name,'createtime >'=>$daytime));
		$access['look_all']=pdo_count('jy_kabao_batch_code',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name,'looktime >'=>0));
		$access['code_all']=pdo_count('jy_kabao_batch_code',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name));
		$access['order_all']=pdo_count('jy_kabao_order',array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name));
		//月份
		for($i=0;$i<12;$i++){
				if($i==0){
					$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
					$yueend = time();
					
				}else{
					$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
					$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
				}
				$params=array($filename=>$filevalue,'uniacid'=>$_SESSION['uniacid'],'pluginname'=>$plugin_name,'looktime >'=>0);
				$params['looktime between']=array($yuestart,$yueend);
				$month12[$i] = date('Y-m',strtotime('-'.$i.' month'));
				//$monthaccess[]=pdo_count('core_access_log',$params);
				$accessline[$i]=pdo_count('jy_kabao_batch_code',$params);
				//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
		}
		$accessline=array_reverse($accessline);
		$month12=array_reverse($month12);
		$return['htmls']=array(
				array('type'=>'data','one_num'=>4,'title'=>'应用今日/总数据指标','datas'=>array(
					array('title'=>'卡片生成数量','num'=>2,'data'=>array($access['code_day'],$access['code_all'])),
					array('title'=>'卡片发放数量','num'=>2,'data'=>array($access['look_day'],$access['look_all'])),
					array('title'=>'卡片领奖数量','num'=>2,'data'=>array($access['order_day'],$access['order_all'])),
				)),
				array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度卡片发放数据','datas'=>array(
					'datas'=>array(
						array('name'=>'卡片发放量','value'=>$accessline),
					),
					'xdatas'=>$month12,
				)),
	);
	exi($return);
}